<!DOCTYPE html>
<title>Tests that invalid media src url does not result in crash.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
function check_invalid_media_src(elementName) {
    async_test(function(t) {
        var mediaElement = document.createElement(elementName);
        mediaElement.src = "!:/" + String.fromCharCode(0) + "%aa#aa";

        mediaElement.onerror = t.step_func_done(function() {
            assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
            assert_equals(mediaElement.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
        });
    });
}

check_invalid_media_src("audio");
check_invalid_media_src("video");
</script>